<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Regions extends GuestController
{
	/**
	* Constructeur
	*/
	public function __construct()
	{
		parent::__construct();
		
		//On change le titre de la page
		parent::setPageName('Découvrir');
		
		//On change la vue du menu
		//On change la vue du menu
		if($this->session->userdata('is_connected') != 1)
		{
			parent::setMenuView('menu/region_menu');
		}
		else
		{
			parent::setMenuView('menu/region_menu_co');
		}
	}
	
	public function choose_user_type($type)
	{
		$this->session->set_userdata('visiteur_type',$type);
		//echo $this->session->userdata('visiteur_type');
		echo '<script>window.location.replace("'.url("regions").'");</script>';
	}
	
	public function show($key_region)
	{
		echo $this->session->userdata('visiteur_type');
		if($key_region != NULL)
		{
			//$region_select = Region::getRegionByKey($key_region);
		
				// choper les type event choix visiteur
				$data['cordinate']= lieux::findCordiante($key_region.', france');
				$data['type_event'] = events::getType_event_visiteur();
				$data['type_lieu'] = lieux::getType_lieu_visiteur();

				parent::loadHeader();
				
			
				$data['region'] =$key_region;
				$this->load->view('notification_zone');
				$this->load->view('home/show_region',$data);
			
				parent::loadFooter();
			
		
		}
		else
		{
			$this->index();
		}
	}

	
	public function create_map()
	{
		header('Content-Type: application/json',true);
		echo json_encode(Region::getAllRegionsJSON());
	}

	
	/**
	 * Page d'accueil
	 */
	public function index()
	{
		parent::loadHeader();
		
		$this->load->view('notification_zone');
		$this->load->view('home/test_region');
		
		parent::loadFooter();
	}

}
